package com.huixuebao.insure.service.impl;


import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.huixuebao.insure.dto.CourseDTO;
import com.huixuebao.insure.entity.CourseEntity;
import com.huixuebao.insure.mapper.CourseMapper;
import com.huixuebao.insure.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 *
 * @author fatao_yu
 * @version 1.0
 * @date 2020-11-01 16:40
 */
@Service
public class CourseServiceImpl implements CourseService {

    @Autowired
    CourseMapper courseMapper;

    @Override
    public List<CourseEntity> listCourse(String merchantUserNo) {
        List<CourseEntity> list = courseMapper.selectList(new LambdaQueryWrapper<CourseEntity>()
                .eq(CourseEntity::getCourseUserNo, merchantUserNo));
        return list;
    }

    @Override
    public CourseDTO getCourse(String courseId) {
        CourseEntity courseEntity = courseMapper.selectOne(new LambdaQueryWrapper<CourseEntity>().eq(CourseEntity::getId, courseId));
        CourseDTO courseDTO = new CourseDTO();
        BeanUtil.copyProperties(courseEntity, courseDTO);
        return courseDTO;
    }
}
